﻿// SyntheticDataGenerator.ParameterSets.CreatorParameters
//
// (c) 2011 Arthur Pitman
//
// Part of Market-Basket Synthetic Data Generator
// A C# adaptation of the IBM Quest Market-Basket Synthetic Data Generator
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// (Version 2) as published by the Free Software Foundation.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public
// License (Version 2) along with this program; if not, write to 
// the Free Software Foundation, Inc., 
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// or see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace SyntheticDataGenerator.ParameterSets
{
	/// <summary>
	/// Creator parameters
	/// </summary>
	public class CreatorParameters
	{
		/// <summary>
		/// Average transaction length
		/// </summary>       
		public double AverageTransactionLength { get; set; }
		
		/// <summary>
		/// Number of items
		/// </summary>
		public int ItemCount { get; set; }
		
		/// <summary>
		/// Parameters for potentially large itemsets
		/// </summary>
		public PatternParameters LisParameters { get; set; }

		/// <summary>
		/// Base filename for output
		/// </summary>
		public string BaseFilename { get; set; }
		
		/// <summary>
		/// Seed to initialize RandSeed with
		/// </summary>
		public int MasterSeed { get; set; }

		/// <summary>
		/// Initializes a new <see cref="CreatorParameters"/> instance with default values
		/// </summary>
		public CreatorParameters()
		{
			LisParameters = new PatternParameters();
			BaseFilename = "";
			MasterSeed = 0;
		}

		/// <summary>
		/// Writes parameters to a <see cref="TextWriter"/>
		/// </summary>
		/// <param name="writer"></param>
		public virtual void Write(TextWriter writer)
		{
			writer.WriteLine("AverageTransactionLength={0}, ItemCount={1}", AverageTransactionLength, ItemCount);
			writer.WriteLine("Filename=\"{0}\", RandSeed={1}", BaseFilename, MasterSeed);
			writer.WriteLine("Large Item Set Patterns:");
			LisParameters.Write(writer);
		}

		public void WriteToFile(string filename)
		{
			var streamWriter = File.CreateText(filename);
			Write(streamWriter);
			streamWriter.Close();
		}

	}
}
